/**
 * 系统后台首页JS-sytemLayout.jsp
 */
var strPath = window.document.location.pathname;
//var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
var postPath = "/gdp";
var localhost = window.document.location.origin;
jQuery(document).ready(function () {
    Metronic.init(); // init metronic core componets
    Layout.init(); // init layout

    //Begin菜单选择样式控制
    //一级菜单
    $(".page-sidebar-menu li").click(function () {
        $(this).parent().children("li").removeClass("active").find(".selected").remove();
        var selectTxt = $(this);
        setTimeout(function () {
            $(selectTxt).addClass("active").children("a").append("<span class='selected'></span>");
        }, 100);
    });

    //二级菜单选择
    $(".sub-menu li").click(function () {
        $(this).parent().children("li").removeClass("active");
        $(this).addClass("active");

        $("#navLoyoutID").html($(this).children("a").find("span").html());

        //页面跳转
        var dataurl = $(this).attr("Dataurl");
        if (dataurl == "pageGenerator/index") {
            $("#sysIframe").attr("src", "/frame-ui-web/pageConfig/index?serviceUrl=" + localhost + postPath);
        } else if (dataurl == "prjtemp/index") {
            $("#sysIframe").attr("src", "/frame-ui-web/prjtemp/index");
        } else {
            $("#sysIframe").attr("src", dataurl);
        }

    });
    //End菜单选择样式控制

    //默认首页
    // $("#sysIframe").attr("src","systemIndex/index");

    $('.menu-a').on('click', function () {
        $("#navLoyoutID").html($(this).text());
    });


});

//iframe高度自适应
function setIframeHeight(iframe) {
    if (iframe) {
        var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
        if (iframeWin.document.body) {
            /* iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; */
            iframe.height = document.documentElement.clientHeight - iframeWin.document.documentElement.scrollHeight + 12;
        }
    }
};
